A three-dimensional (3D) graphics system (which also may be referred to herein as a rendering system) is designed to render an image of a 3D scene on a two-dimensional (2D) screen. Specifically, an application (e.g. a video game) generates a 3D model of the scene and outputs geometry data representing the objects in the scene. In particular, the application divides each object into a plurality of primitives (i.e. simple geometric shapes, such as triangles, lines and points) which are defined by the positions of one or more vertices. The geometry data output by the application includes information identifying each vertex (e.g. the coordinates of the vertex) and information indicating the primitives formed by the vertices. The graphics system then converts the received geometry data into an image displayed on the screen.
A 3D graphics system typically has two main stages—a geometry processing stage and a rasterization stage. During the geometry processing stage the vertices received from the application are transformed from a world window 102 (i.e. world space coordinates) to a viewport 104 (i.e. screen space coordinates) as shown in FIG. 1A, which is referred to herein as a viewport transformation. The world window 102 is the area of the scene 106 in application-specific coordinates (e.g. kilometres, or centimetres) that the user wants to visualize. In contrast, the viewport 104 is an area of the screen 108 in rendering-device specific coordinates (e.g. pixels or sampling positions) used to display the image of the scene. The viewport 104 may be the whole screen 108 or a portion thereof. Accordingly, the viewport transformation translates the incoming world space coordinates in the world window 102 to screen space coordinates in the viewport 104.
In many cases (e.g. as shown in FIG. 1A), the geometry processing stage uses a single viewport (typically with dimensions that cover the entire screen) at a time and the coordinates of all vertices are transformed to this viewport. However, some applications (such as, but not limited to, geometry shaders) may use multiple viewports to achieve one or more visual effects. For example, in some cases it may be desirable to render to a smaller window within the screen and/or to multiple windows within the screen. In other examples, some applications may implement layered rendering wherein specific primitives may be sent to different layers (each associated with a different viewport) of a layered framebuffer to, for example, implement cube-based shadow mapping. For example, as shown in FIG. 1B there may be two viewports 110 and 112 in the screen 108 and a first and second primitive 114 and 116 are rendered in the first viewport 110 and a third primitive 118 is rendered in the second viewport 112 In these cases, the geometry data output by the application may include information indicating the viewport associated with each primitive which allows the coordinates of vertices of different primitives to be mapped to different viewports. The geometry processing stage also typically includes forming primitives from the received vertices, prior to, or after, the viewport transformations thereof.
During the rasterization stage the primitives are mapped to pixels and the colour of each pixel is determined. This may comprise identifying which primitive(s) are visible at each pixel. The colour of each pixel may then be determined by the texture of the visible primitive(s) at that pixel and/or the pixel shader program run on that pixel. A pixel shader program describes operations that are to be performed for given pixels. Once a colour value has been identified for each pixel the colour values are written out to a frame buffer in memory and then displayed on the screen.
The embodiments described below are provided by way of example only and are not limiting of implementations which solve any or all of the disadvantages of known viewport transformation systems.